﻿// Write a program that gets a number n and after that gets more n numbers and calculates and prints their sum. 

using System;

class SumNNumbers
{
    static void Main()
    {
        Console.Write("Enter number n : ");
        string numberStr = Console.ReadLine();
        uint number;
        if (uint.TryParse(numberStr, out number))
        {
            double sum = 0;

            for (int i = 1; i <= number; i++)
            {
                Console.Write("Enter number {0} : ", i);
                string numberNew = Console.ReadLine();
                double j;
                if (double.TryParse(numberNew, out j))
                {
                    sum += j;
                }
                else
                {
                    Console.WriteLine("The entered number is invalid!");
                }
            }

            Console.WriteLine("\nThe sum of all entered numbers is: {0}\n", sum);
        }
        else
        {
            Console.WriteLine("The entered number is invalid!");
        }
    }
}
